<template>
  <div class="home">
    Home
    <el-button type="primary" @click="loadApp">手动加载</el-button>
    <div id="hand-micro-app"></div>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import { loadMicroApp } from 'qiankun';

export default {
  name: 'HomeView',
  components: {
    HelloWorld
  },
  data() {
    return {
      microApp: null,
    };
  },
  methods: {
    loadApp() {
      this.microApp = loadMicroApp({
        name: 'otherApp',
        entry: 'http://localhost:9999/',
        container: '#hand-micro-app',
        props: {
          data: {
            name: '123s',
          }
        },
      });
    }
  },
  beforeDestroy() {
    if (this.microApp) {
      this.microApp.unmount();
    }
  },
}
</script>